import {
  Component,
  OnInit,
  OnChanges,
  SimpleChanges,
  Input,
  Output,
  EventEmitter
} from '@angular/core';
import {
  Meta,
  Title
} from '@angular/platform-browser';
import {
  FormsModule
} from '@angular/forms';
import { Pipe, PipeTransform } from '@angular/core';

@Component({
  selector: 'app-list2',
  templateUrl: './list2.component.html',
  styleUrls: ['./list2.component.scss']
})
export class List2Component implements OnInit {
  @Input() c3:number=500;
  @Input() c4:number=50;
  @Input() c5:number=29;
  @Output() c6:number;

  // Case One
  @Output() e10:number;
  @Input() e11:number=150;
  @Input() e12:number=500;
  @Output() e14:number;
  @Input() e15:number=219000;
  @Output() e16:number;

  @Input() c19:number=38;
  @Input() c20:number=20;
  @Input() c21:number=6;
  @Input() c22:number=5;
  @Input() c23:number=1.5;
  @Input() c24:number=1;
  @Input() c25:number=2;
  @Input() c26:number=30;
  @Input() c27:number=200;
  @Input() c28:number=5;

  @Output() e19:number;
  @Output() e20:number;
  @Output() e21:number;
  @Output() e22:number;
  @Output() e23:number;
  @Output() e24:number;
  @Output() e25:number;
  @Output() e26:number;
  @Output() e27:number;
  @Output() e28:number;

  @Output() e29:number;
  @Output() e30:number;
  @Output() e31:number;
  
  // Case Two
  @Input() h3:number=500;
  @Input() h4:number=30;
  @Input() h5:number=17;
  @Output() h6:number;

  @Input() j10:number=120;
  @Input() j11:number=150;
  @Input() j12:number=300;

  @Output() j14:number;
  @Output() j15:number;
  @Output() j16:number;

  @Input() h19:number=this.c19;
  @Input() h20:number=this.c20;
  @Input() h21:number=this.c21;
  @Input() h22:number=this.c22;
  @Input() h23:number=this.c23;
  @Input() h24:number=this.c24;
  @Input() h25:number=this.c25;
  @Input() h26:number=this.c26;
  @Input() h27:number=this.c27;
  @Input() h28:number=this.c28;

  @Output() j19:number;
  @Output() j20:number;
  @Output() j21:number;
  @Output() j22:number;
  @Output() j23:number;
  @Output() j24:number;
  @Output() j25:number;
  @Output() j26:number;
  @Output() j27:number;
  @Output() j28:number;

  @Output() j29:number;
  @Output() j30:number;

  @Output() j31:number;
  @Output() j32:number;
  @Output() j33:number;

  @Output() m9:number;
  @Input() m10:number=300;
  @Input() m11:number=10;
  @Output() m12:number;

  constructor() {
    this.recal_all();
  }

  ngOnInit() {
    // this.recal();
  }

  recal_1(){
    // Sync Case One to Case Two
    this.h19 = this.c19;
    this.h20 = this.c20;
    this.h21 = this.c21;
    this.h22 = this.c22;
    this.h23 = this.c23;
    this.h24 = this.c24;
    this.h25 = this.c25;
    this.h26 = this.c26;
    this.h27 = this.c27;
    this.h28 = this.c28;

    this.recal_all();
  }

  recal_2(){
    // Sync Case Two to Case One
    this.c19 = this.h19;
    this.c20 = this.h20;
    this.c21 = this.h21;
    this.c22 = this.h22;
    this.c23 = this.h23;
    this.c24 = this.h24;
    this.c25 = this.h25;
    this.c26 = this.h26;
    this.c27 = this.h27;
    this.c28 = this.h28;

    this.recal_all();
  }

  recal_all(){
    // Case One
    // 设定
    this.c6 = this.c4 + this.c5;
    this.e10 = (this.e15 / this.e12) * 100 / 365;
    this.e14 = this.e10 * this.e11 / 100;
    this.e16 = this.e11 * this.e15;

    this.e19 = this.e16 * this.c19 / 100;
    this.e20 = this.e16 * this.c20 / 100;
    this.e21 = this.e16 * this.c21 / 100;
    this.e22 = this.e16 * this.c22 / 100;
    this.e23 = this.e16 * this.c23 / 100;
    this.e24 = this.e16 * this.c24 / 100;
    this.e25 = this.e16 * (this.c26/100) * (this.c25/100);
    
    this.e27 = this.c6 * this.c27;
    this.e28 = this.e16 * this.c28 / 100;
    this.e29 = this.e19 + this.e20 + this.e21 + this.e22 + this.e23 + this.e24 + this.e25 + this.e27 + this.e28;

    this.e30 = this.e16 - this.e29;
    this.e31 = this.e30 * 100 / this.e16;


    // Case Two
    this.h6 = this.h4 + this.h5;

    this.j14 = this.j10 * this.j11 / 100;
    this.j15 = this.j12 * 365 * this.j10 / 100;
    this.j16 = this.j11 * this.j15;

    this.j19 = this.j16 * this.h19 / 100;
    this.j20 = this.j16 * this.h20 / 100;
    this.j21 = this.j16 * this.h21 / 100;
    this.j22 = this.j16 * this.h22 / 100;
    this.j23 = this.j16 * this.h23 / 100;
    this.j24 = this.j16 * this.h24 / 100;
    this.j25 = this.j16 * (this.h26/100) * (this.h25/100);

    this.j27 = this.h6 * this.h27;
    this.j28 = this.j16 * this.h28 / 100;

    this.j29 = this.j19 + this.j20 + this.j21 + this.j22 + this.j23 + this.j24 + this.j25 + this.j27 + this.j28;
    
    this.j30 = this.j16 - this.j29;

    this.m9 = this.c3 - this.j12;
    this.m12 = this.m10 * this.m11 * 365;

    this.j31 = this.m12;
    this.j32 = this.j30 + this.j31;
    this.j33 = this.j32 / this.j16 * 100;
  }
}
